﻿var voted = 0;
$(window).load(function()
{
    var x = $(".rating").attr("class");
    if (x == "rating") {
        var score = $(".hiddenscore input").val();
        if (score == "NaN") {
            score = "0.00";
        }
        var schaap = score.replace(",", ".");
        $(".stars").css({ width: parseFloat(schaap) * 27 });
    }
    $("#menu").css("height", $("#content").height() + 10);
    $("#content").css("height", $("#menu").height() - 10);
});
function cover_click() {
    $("#popup_cover").show();
    $(".background_opacity").show();
    $(".background_opacity").css("height", $(document).height());
}
function closePopup() {
    $("#popup_cover").hide();
    $(".background_opacity").hide();
}
function review_click() {
    $("#popup_review").fadeIn();
    $(".background_opacity").css("height", $(document).height());
    $(".background_opacity").fadeIn();
    
    var starwidth;
    var starwidthKlik = 0;

    $(".starbg").mousemove(function(e) {
        // limit stars to move in whole stars
        var offset = $(this).offset();
        var position = e.pageX - parseInt(offset.left);
        starwidth = (parseInt((position) / 27) + 1) * 27;
        //if ($(currentimage).find("hasvoted").text()=="false") {
        $(".stars").css({ width: starwidth });
        //}
    }).mouseout(function() {
        // reset stars to current voting score
        $(".stars").css({ width: starwidthKlik });
    }).click(function(e) {
        var offset = $(this).offset();
        var position = e.pageX - parseInt(offset.left);
        var starwidth = (parseInt((position) / 27) + 1) * 27;
        var newscore = parseInt($(".stars").css("width"));
        var score = (parseInt((newscore) / 27));
        starwidthKlik = (parseInt((position) / 27) + 1) * 27;
        $(".hidden input").val(score);
        voted = 1;
    });
}
function review_closePopup() {
    $("#popup_review").fadeOut();
    $(".background_opacity").fadeOut();
}
function login_closePopup() {
    $("#popup_login").fadeOut();
    $(".background_opacity").fadeOut();
}
function wijzig_closePopup() {
    $("#popup_wijzig").fadeOut();
    $(".background_opacity").fadeOut();
}
function niet_ingelogd() {
    $("#popup_login").fadeIn();
    $(".background_opacity").fadeIn();
    $(".background_opacity").css("height", $(document).height());
}
function wijzigen_click() {
    $("#popup_wijzig").fadeIn();
    $(".background_opacity").fadeIn();
    $(".background_opacity").css("height", $(document).height());
}
